﻿#include "selectionsort.h"

#include <QDebug>

SelectionSort::SelectionSort()
{

}

void SelectionSort::sort(int *arr, int N)
{
    qDebug() << "selection sort:";
    int i, j, k;
    for (i = 0; i<N; i++) {
        k = i;
        for (j = i + 1; j<N; j++) {
            if (arr[j] < arr[k]){
                k = j;
            }
        }
        int temp = arr[i];
        arr[i] = arr[k];
        arr[k] = temp;
    }
}
